package com.levy.contronller.javaWeb.t;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 郭利伟 on 2017.08.23.
 */
public class TTest {
    private static <T> String test1(List<T> list) throws Exception {
        String n = "";
        Class c = list.get(0).getClass();
        Field[] fields = c.getDeclaredFields();
        for(Field f:fields){
            f.setAccessible(true);
            System.out.println(f.getName());
        }


        return n;
    }


    public static void main(String[] args) throws Exception {
        List<Person> lp = new ArrayList<Person>();
        Person p1 = new Person();
        p1.setName("jack");
        p1.setSex("1");
        lp.add(p1);
        Person p2 = new Person();
        p2.setSex("2");
        p2.setName("rose");
        lp.add(p2);
        String ddd = test1(lp);
        System.out.println(ddd);
    }
}
